﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace MediaRecommender.Model
{
    public abstract class AssociatedPerson : IEquatable<AssociatedPerson>
    {
        #region AssociatedPeople
        public string Name { get; set; }
        public List<Media> AssociatedMedia { get; set; }

        public AssociatedPerson(string name)
        {
            this.Name = name;
            this.AssociatedMedia = new List<Media>();
        }
        #endregion

        #region Equals
        public override int GetHashCode()
        {
            return this.Name.GetHashCode();
        }

        public override bool Equals(object obj)
        {
            if (obj == null)
                return false;

            if (this.GetType() != obj.GetType())
                return false;

            return Equals((AssociatedPerson)obj);
        }

        public bool Equals(AssociatedPerson obj)
        {
            if (obj == null)
                return false;

            if (ReferenceEquals(this, obj))
                return true;

            if (this.AssociatedMedia.GetType() != obj.AssociatedMedia.GetType())
                return false;

            if (this.GetHashCode() != obj.GetHashCode())
                return false;

            return this.Name.Equals(obj.Name);
        }

        public static bool operator ==(AssociatedPerson leftAssPeron, AssociatedPerson rightAssPerson)
        {
            if (ReferenceEquals(leftAssPeron, null))
            {
                return ReferenceEquals(rightAssPerson, null);
            }

            return (leftAssPeron.Equals(rightAssPerson));
        }

        public static bool operator !=(AssociatedPerson leftAssPeron, AssociatedPerson rightAssPerson)
        {
            return !(leftAssPeron == rightAssPerson);
        }
        #endregion
    }

    public class Actor : AssociatedPerson
    {
        #region Actor

        public Actor(string name)
            : base(name)
        { }
        #endregion
    }

    public class Director : AssociatedPerson
    {
        #region Director

        public Director(string name)
            : base(name)
        { }
        #endregion
    }

    public class Author : AssociatedPerson
    {
        #region Author

        public Author(string name)
            : base(name)
        { }
        #endregion
    }

    public class GameStudio : AssociatedPerson
    {
        #region GameStudio

        public GameStudio(string name)
            : base(name)
        { }
        #endregion
    }

    public class Publisher : AssociatedPerson
    {
        #region Publisher

        public Publisher(string name)
            : base(name)
        { }
        #endregion
    }
}